package com.robert.util;

import lombok.Data;

/**
 * <p>
 *
 * </p>
 *
 * @author robert zhao
 * @since 2020/5/6
 */
@Data
public class Pager {

  private Integer currentNum;

  private Integer startIndex;

  private Integer lastIndex;

  private Integer total;

  public Integer getStartIndex() {
    if (currentNum <= 0 ) {
      currentNum = 1;
    }
    return (currentNum - 1) * 10 ;
  }

  public Integer getLastIndex() {
    if (currentNum < 0) {
      currentNum = 0;
    }
    return (currentNum + 1) * 10;
  }

  public Integer getCurrentNum() {
    if (currentNum * 10 > total) {
      currentNum = currentNum - 1;
    }
    return currentNum;
  }
}
